import { request } from '../request';
// import { parseMenuMeta } from '../request/shared';

/** 获取角色列表 */
export function fetchGetRoleList(data?: ManageApi.RoleManage.RoleSearchParams) {
  return request<ManageApi.RoleManage.RoleList>({
    url: '/api/v1/role/queryRoleList',
    method: 'post',
    data
  });
}

/** 新建角色 */
export function fetchAddRole(data: ManageApi.RoleManage.AddRoleParams) {
  return request({
    url: '/api/v1/role/insertRole',
    method: 'post',
    data
  });
}

/** 编辑角色 */
export function fetchEditRole(data: ManageApi.RoleManage.EditRoleParams) {
  return request({
    url: '/api/v1/role/updateRole',
    method: 'post',
    data
  });
}

/** 删除角色 */
export function fetchDeleteRole(data: ManageApi.RoleManage.DeleteRoleParams) {
  return request({
    url: '/api/v1/role/deleteRole',
    method: 'post',
    data
  });
}

/**
 * 获取全部权限
 *
 * 已启用的全部角色
 */
export function fetchGetAllRoles() {
  return request<ManageApi.RoleManage.AllRole[]>({
    url: '/api/v1/sysManage/getAllRoles',
    method: 'post'
  });
}

/** 获取用户列表 */
export function fetchGetUserList(data?: ManageApi.UserManage.UserSearchParams) {
  return request<ManageApi.UserManage.UserList>({
    url: '/api/v1/user/queryUserList',
    method: 'post',
    data
  });
}

/** 新建用户 */
export function fetchAddUser(data: ManageApi.UserManage.AddUserParams) {
  return request({
    url: '/api/v1/user/insertUser',
    method: 'post',
    data
  });
}

/** 编辑用户 */
export function fetchEditUser(data: ManageApi.UserManage.EditUserParams) {
  return request({
    url: '/api/v1/user/updateUser',
    method: 'post',
    data
  });
}

/** 删除用户 */
export function fetchDeleteUser(data: ManageApi.UserManage.DeleteUserParams) {
  return request({
    url: '/api/v1/user/deleteUser',
    method: 'post',
    data
  });
}

/** 获取租户列表 */
export function fetchGetTenantList(data?: ManageApi.TenantManage.TenantSearchParams) {
  return request<ManageApi.TenantManage.TenantList>({
    url: '/api/v1/tenant/queryTenantList',
    method: 'post',
    data
  });
}

/** 新建租户 */
export function fetchAddTenant(data: ManageApi.TenantManage.AddTenantParams) {
  return request({
    url: '/api/v1/tenant/insertRole',
    method: 'post',
    data
  });
}

/** 编辑租户 */
export function fetchEditTenant(data: ManageApi.TenantManage.EditTenantParams) {
  return request({
    url: '/api/v1/tenant/updateTenant',
    method: 'post',
    data
  });
}

/** 删除租户 */
export function fetchDeleteTenant(data: ManageApi.TenantManage.DeleteTenantParams) {
  return request({
    url: '/api/v1/tenant/deleteTenant',
    method: 'post',
    data
  });
}

/** 新建菜单/目录 */
export function fetchAddMenu(data: ManageApi.MenuManage.AddMenuParams) {
  return request({
    url: '/api/v1/sys/insertMenu',
    method: 'post',
    data
  });
}

/** 编辑菜单/目录 */
export function fetchEditMenu(data: ManageApi.MenuManage.EditMenuParams) {
  return request({
    url: '/api/v1/sys/updateMenu',
    method: 'post',
    data
  });
}

/** 删除菜单/目录 */
export function fetchDeleteMenu(data: ManageApi.MenuManage.DeleteMenuParams) {
  return request({
    url: '/api/v1/sys/deleteMenu',
    method: 'post',
    data
  });
}

/** 获取菜单列表 */
export function fetchGetMenuList() {
  return request<ManageApi.MenuManage.MenuList>({
    url: '/api/v1/sys/queryMenuList',
    method: 'post'
  });
}

/** 获取所有页面 */
export function fetchGetAllPages() {
  return request<string[]>({
    url: '/api/v1/sys/queryRouteNameList',
    method: 'post'
  });
}

/** 获取菜单树 */
export function fetchGetMenuTree() {
  return request<ManageApi.MenuManage.MenuTree[]>({
    url: '/api/v1/sysManage/getMenuTree',
    method: 'post'
  });
}

/** 获取字典列表 */
export function fetchGetDictList(data: ManageApi.DictManage.DictSearchParams) {
  return request<ManageApi.DictManage.DictList>({
    url: '/api/v1/sysManage/getDictList',
    method: 'post',
    data
  });
}

/** 获取日志列表 */
export function fetchGetLogtList(data: ManageApi.LogManage.LogSearchParams) {
  return request<ManageApi.LogManage.LogList>({
    url: '/api/v1/sysManage/getLogList',
    method: 'post',
    data
  });
}
